﻿#region Using Directives

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Xml.Linq;

    using Csla;

    using MarketPulse.BusinessLogic.Core;

#endregion

namespace MarketPulse.BusinessLogic.Private
{
    /// <summary>
    /// This class represents a collection of Accreditation objects
    /// </summary>
    [Serializable]
    [Csla.Server.ObjectFactory("MarketPulse.DataAccess.Factory.AccreditationFactory, MarketPulse.DataAccess.Factory", "CreateList", "FetchList")]
    public class AccreditationList : MarketPulseListBase<AccreditationList, Accreditation>
    {

        #region Constructors

            /// <summary>
            /// Default constructor is private in order to (try to) enforce construction
            /// only via the static factory methods provided.
            /// </summary>
            private AccreditationList()
            {
            }

        #endregion

        #region Methods

            #region Factory Methods

                ///// <summary>
                ///// Method used to create a new collection of Accreditation objects (via the DataPortal client proxy)
                ///// </summary>
                ///// <returns>The newly created collection of Accreditation objects</returns>
                //internal static AccreditationList New()
                //{
                //    return DataPortal.Create<AccreditationList>();
                //}

                /// <summary>
                /// Method used to get a list of Accreditations that are currently not obsolete
                /// </summary>                
                /// <returns>The populated Accreditation collection</returns>
                public static AccreditationList GetAllActive()
                {
                    return DataPortal.Fetch<AccreditationList>();
                }

            #endregion

            /// <summary>
            /// Method used to find a single AccreditationInfo object from the collection based on the unique identifier supplied
            /// </summary>
            /// <param name="accreditationGUID">The GUID that uniquely identifies the Accreditation Info object to find</param>
            /// <returns>A populated Accreditation Info object</returns>
            public Accreditation FindByGUID(Guid accreditationGUID)
            {
                var result = (from accreditation in this.Items
                                where accreditation.GUID.Value == accreditationGUID
                                select accreditation).Single();

                return (Accreditation)result;
            }

        #endregion
    }
}
